fix: resolve Issue #12 — ac.mjs no longer silently falls back to source repo - #13
Merged
Conversation
…ce repo
resolveRoot() previously returned new URL('../agent-context', import.meta.url)
when cwd had no project, polluting the package source (or npx cache) with
user data. Now it prints a clear bilingual error and exits 1, requiring an
initialized agent-context in cwd.
Repro: run ac.mjs outside a project dir -> exit 1 + error, source repo untouched.
e2e-workflow.mjs 6/6 still pass. (ac-watch.mjs/ac-fts.mjs share the pattern;
filed separately as future work.)
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12, part (A) only — the critical data-pollution bug.
tools/ac.mjsresolveRoot()previously fell back tonew URL('../agent-context', import.meta.url)when the current working directory had neitheragent-context.config.jsonnoragent-context/. When invoked from a wrong/empty directory (e.g. by an automation script that didn't setcwd, or vianpx), it silently wrote user entries into the package source (or npx cache) and regeneratedindex.json/graph.json— polluting the install.Now
resolveRoot()prints a clear bilingual error andprocess.exit(1)instead of falling back:Dogfooding from the repo root still works because the repo root itself contains
agent-context.config.json+agent-context/(cwd detection branch unchanged).Verification
git show HEAD~1:tools/ac.mjsshowed the silentnew URL('../agent-context', ...).pathnamefallback.ac.mjsfrom a clean dir with no project → exit code 1 + bilingual error;git statusof the repo shows no pollution ofagent-context/(index.json/graph.json untouched, no new files).node --check tools/ac.mjspasses.node tools/e2e-workflow.mjs→ all 6 steps pass.Out of scope (filed as future work)
Part (B) of #12 (synonym dict expansion + search-lite padding/threshold) is not addressed here, per task scope.
The same silent directory fallback also exists in
ac-watch.mjsandac-fts.mjs(and many tools read the sourceagent-context.config.jsonwhen cwd has no project) — noted for a follow-up issue, not changed in this PR.🤖 Generated with opencode